import request from '@/utils/request'

// 获取商品列表
export function getItemList(params) {
  // 转换分页参数
  const { page, page_size, ...otherParams } = params
  const queryParams = {
    skip: (page - 1) * page_size,
    limit: page_size,
    ...otherParams
  }
  return request({
    url: '/api/shop/products/',
    method: 'get',
    params: queryParams
  })
}

// 获取商品详情
export function getItemDetail(id) {
  return request({
    url: `/api/shop/products/${id}`,
    method: 'get'
  })
}

// 创建商品
export function createItem(data) {
  return request({
    url: '/api/shop/products/',
    method: 'post',
    data
  })
}

// 更新商品
export function updateItem(id, data) {
  return request({
    url: `/api/shop/products/${id}`,
    method: 'put',
    data
  })
}

// 删除商品
export function deleteItem(id) {
  return request({
    url: `/api/shop/products/${id}`,
    method: 'delete'
  })
} 